package com.runner.services;

import com.runner.observer.Event;
import com.runner.observer.Observer;
import com.runner.utility.Constants;
import com.runner.utility.Locator;

public class Achievements implements Observer, Constants {

	private boolean hoarder;
	private boolean unlock;
	private boolean ringer1;
	private boolean ringer2;
	private boolean april1;
	private boolean april2;
	private boolean geo1;
	private boolean geo2;
	private boolean ringerShield;
	private boolean aprilShield;
	private boolean geoShield;

	public Achievements() {

	}

	public boolean completed() {
		return hoarder && unlock && ringer1 && ringer2 && april1 && april2 
				&& geo1 && geo2 && ringerShield && aprilShield && geoShield;

	}

	@Override
	public void onNotify(Event event) {
		if (!completed()) {
			switch (event) {
			case EVENT_RINGER1_TRACK:
				unlock(ACHV_RINGER1_TRACK);
				ringer1 = true;
				break;
			case EVENT_RINGER2_TRACK:
				unlock(ACHV_RINGER2_TRACK);
				ringer2 = true;
				break;
			case EVENT_APRIL1_TRACK:
				unlock(ACHV_APRIL1_TRACK);
				april1 = true;
				break;
			case EVENT_APRIL2_TRACK:
				unlock(ACHV_APRIL2_TRACK);
				april2 = true;
				break;
			case EVENT_GEO1_TRACK:
				unlock(ACHV_GEO1_TRACK);
				geo1 = true;
				break;
			case EVENT_GEO2_TRACK:
				unlock(ACHV_GEO2_TRACK);
				geo2 = true;
				break;
			case EVENT_RINGER2_TRACK_SHIELD:
				unlock(ACHV_RINGER2_TRACK_SHIELD);
				ringerShield = true;
				break;
			case EVENT_APRIL2_TRACK_SHIELD:
				unlock(ACHV_APRIL2_TRACK_SHIELD);
				aprilShield = true;
				break;
			case EVENT_GEO2_TRACK_SHIELD:
				unlock(ACHV_GEO2_TRACK_SHIELD);
				geoShield = true;
				break;
			case EVENT_UNLOCK:
				unlock(ACHV_UNLOCK);
				unlock = true;
				break;
			case EVENT_HOARDER:
				unlock(ACHV_HOARDER);
				hoarder = true;
				break;
			default:
				break;
			}
		}

	}

	public void unlock(String id) {
		Locator.getDevice().unlockAchievements(id);

	}

	public boolean isHoarder() {
		return hoarder;
	}

	public boolean isUnlock() {
		return unlock;
	}

	public boolean isRinger1() {
		return ringer1;
	}

	public boolean isRinger2() {
		return ringer2;
	}

	public boolean isApril1() {
		return april1;
	}

	public boolean isApril2() {
		return april2;
	}

	public boolean isGeo1() {
		return geo1;
	}

	public boolean isGeo2() {
		return geo2;
	}

	public boolean isRingerShield() {
		return ringerShield;
	}

	public boolean isAprilShield() {
		return aprilShield;
	}

	public boolean isGeoShield() {
		return geoShield;
	}

	public void setHoarder(boolean hoarder) {
		this.hoarder = hoarder;
	}

	public void setUnlock(boolean unlock) {
		this.unlock = unlock;
	}

	public void setRinger1(boolean ringer1) {
		this.ringer1 = ringer1;
	}

	public void setRinger2(boolean ringer2) {
		this.ringer2 = ringer2;
	}

	public void setApril1(boolean april1) {
		this.april1 = april1;
	}

	public void setApril2(boolean april2) {
		this.april2 = april2;
	}

	public void setGeo1(boolean geo1) {
		this.geo1 = geo1;
	}

	public void setGeo2(boolean geo2) {
		this.geo2 = geo2;
	}

	public void setRingerShield(boolean ringerShield) {
		this.ringerShield = ringerShield;
	}

	public void setAprilShield(boolean aprilShield) {
		this.aprilShield = aprilShield;
	}

	public void setGeoShield(boolean geoShield) {
		this.geoShield = geoShield;
	}

}
